#ifndef DOWNQUICK_H
#define DOWNQUICK_H

#include <QWidget>
#include<QKeyEvent>
#include<QMouseEvent>
#include<QPaintEvent>
#include<QVector>
#include<QPixmap>

#include<helpfunction.h>

namespace Ui {
class DownQuick;
}

class DownQuick : public QWidget
{
    Q_OBJECT

public:
    explicit DownQuick(QWidget *parent = nullptr);
    ~DownQuick();
    void keyPressEvent(QKeyEvent *k);
    void mousePressEvent(QMouseEvent *m);
    virtual void timerEvent(QTimerEvent *event);

    void setPosition(int x,int y);
    int npc_X;
    int npc_Y;
    //矩形边框
    QRect npc_Rect;
private:
    Ui::DownQuick *ui;
protected:
     std::vector<std::vector<int>> initMatrix();
    void paintEvent(QPaintEvent *event);
    QVector<QVector<int>> gameMatrix; // 7x7 游戏矩阵
    QPixmap emptyPixmap;             // 空地的图片
    QPixmap spikesPixmap;           // 尖刺的图片
    QPixmap stairPixmap;        // 下楼的图片
    QPixmap foodPixmap;
    QPixmap getPixmapForCell(int value);
    void updateMatrix(int value,int tovalue);
    int myTimerId;
    int picID;

    bool isStart();
    int Score=0;
    int Time=10000;
    int Floor=1;
    bool SpaceTickTwice=0;
private slots:
    void on_dqStartButton_clicked();
    void on_dqGiveUpButton_clicked();
};

#endif // DOWNQUICK_H
